#include "HT162X_Parts.h"
#include "../main.h"
#include "../MCU_Mold/MCU_F_C_Convert.h"

#ifndef UI_H
#define UI_H

#define Oven_Setting_Min_F 165 //F
#define Oven_Setting_Max_F 450 //F
#define Probe_Setting_Min_F 140 //F
#define Probe_Setting_Max_F 215 //F
#define Alarm_Probe_Min 0 //F

#define Oven_Setting_Min_C 75 //C
#define Oven_Setting_Max_C 230 //C
#define Probe_Setting_Min_C 60 //C
#define Probe_Setting_Max_C 100 //C

typedef enum
{
    Alarm_None = 0,
    Alarm_Timer1,
    Alarm_RTD,
    Alarm_ProbeA_Enable,
    Alarm_ProbeA_Action,
    Alarm_ProbeB_Enable,
    Alarm_ProbeB_Action,
}UI_Alarm_E;
typedef enum
{
    UI_OFF = Char_OFF,
    UI_ON = Char_ON,
}UI_State_E;
typedef enum
{
    UI_None = 0,
    UI_RTD,
    UI_RTDSettings,
    UI_Timer_Hour,
    UI_Timer_Minute,
    UI_ProbeA,
    UI_ProbeB,
}UI_Number_E;
typedef enum
{
    Shine_All = 0, //所有段码闪耀
    Shine_Init,
    Shine_OFF, //正常不闪耀
    Shine_ON, //闪耀
}Shine_E;
typedef enum
{
    Alart_None = 0,
    Alart_Action,
}Alart_Type;
typedef struct
{
    int64_t Actual;
    uint64_t Settings;   
    uint8_t IsChanged;
    Alart_Type Alart_State;
}UI_Param_Typedef;
typedef struct 
{
    UI_Param_Typedef RTD;
    UI_Param_Typedef ProbeA;
    UI_Param_Typedef ProbeB;
    UI_Param_Typedef Timer1;
    // MCU_Time_T Timer1_T;
    Shine_E Shine;
    Shine_E Shine_Colon;
    Shine_E Shine_WIFI;
    uint8_t ShineCtrl;

    Grill_State_E Grill_state;
    Grill_State_E Grill_Smoke;
    UI_State_E State_TempCtrl;
    UI_Number_E State_Operation;
    UI_State_E ICO_WIFI;
    UI_State_E ICO_Bluetooth;
    UI_State_E ICO_Auger;
    UI_State_E ICO_Fan;
    UI_State_E ICO_Heating;
    UI_State_E ICO_Error;
    UI_State_E ICO_Error_Auger; 
    UI_State_E ICO_Error_Fan; 
    UI_State_E ICO_Error_Ignite; 
    UI_State_E ICO_Cell;
    UI_State_E OTA_Check;

    UI_State_E Is_Reset;

    UI_Alarm_E Alarm_Timer;
    UI_Alarm_E Alarm_RTD;
    UI_Alarm_E Alarm_ProbeA;
    UI_Alarm_E Alarm_ProbeB;

    Grill_Unit_E Grill_Unit;
}UI_System_S;
extern UI_System_S UI_System;

void UI_Encoder_KeyLong(void);
void UI_Encoder_Key(void);
void UI_Encoder_R(void);
void UI_Encoder_L(void);
void UI_Clock(void);
void UI_Init(void);
void UI_Main(void);
void UI_Shine_Exit(void);
void UI_TempCtrl_Start(void);
void UI_TempCtrl_Stop(void);

UI_State_E UI_Grill_Normal(void);

uint16_t Get_F_Gear(uint16_t C, uint16_t minFGear, uint16_t minCGear);
uint16_t Get_C_Gear(uint16_t F, uint16_t minCGear, uint16_t minFGear);
void UI_Default_F(void);
void UI_Default_C(void);

#endif
